﻿<c:BaseControl x:Class="personalplaner.gui.plugins.dienstplan.views.DienstPlanView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:c="clr-namespace:personalplaner.common.controls;assembly=personalplaner.common"
             xmlns:k="clr-namespace:personalplaner.common.themes;assembly=personalplaner.common"
             xmlns:vm="clr-namespace:personalplaner.common.mvvm.factory;assembly=personalplaner.common"
             xmlns:fac="clr-namespace:personalplaner.gui.plugins.dienstplan.viewmodels.factories"
             vm:ViewModelLoader.FactoryType="{x:Type fac:DienstPlanModelFactory}"
             xmlns:conv="clr-namespace:personalplaner.common.converters;assembly=personalplaner.common"
             xmlns:bp="clr-namespace:personalplaner.business.dienstplan;assembly=personalplaner.business"
               xmlns:p="clr-namespace:personalplaner.gui.Properties">
    
    <Control.Resources>

        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <!--<ResourceDictionary Source="/personalplaner.gui;component/resources/PlanMenuTemplate.xaml"/>-->
                <ResourceDictionary>
                    <conv:ColorToSolidColorBrushConverter x:Key="colorToBrush"/>

                    <DataTemplate x:Key="itemTemplate" DataType="{x:Type bp:PlanItem}">
                        <Grid>
                            <Border Background="{Binding Color, Converter={StaticResource colorToBrush}}"/>
                            <TextBlock Text="{Binding Name}"/>
                        </Grid>
                    </DataTemplate>

                    <Style x:Key="itemStyle" TargetType="TextBlock">
                        <Setter Property="Text" Value="{Binding Name}"/>
                        <Setter Property="Background" Value="{Binding Color, Converter={StaticResource colorToBrush}}"/>
                    </Style>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>

    </Control.Resources>

    <Control.InputBindings>
        <!-- Group Allgemeine Stammdaten-->
        <KeyBinding Key="P" Modifiers="Ctrl" Command="{Binding PrintCommand}" />
    </Control.InputBindings>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>


        <Border Name="Border" BorderThickness="0" Background="Transparent" CornerRadius="4,4,0,0" VerticalAlignment="Top" Height="25">
            <Grid>
                <Menu Grid.Column="1" >
                    <MenuItem> 
                        <MenuItem.Header>
                                <!--<TextBlock Name="mainMenu" Text="{Binding Collection.Name}" HorizontalAlignment="Left" Margin="0,0,20,0" Foreground="#E1FFFFFF" VerticalAlignment="Center" FontWeight="Bold">Foreground="{DynamicResource {x:Static k:ResourceKeys.ForegroundBrush}}"-->
                                <TextBlock Name="mainMenu" Text="{Binding Collection.Name}" HorizontalAlignment="Left" Margin="0,0,20,0"  VerticalAlignment="Center" FontWeight="Bold">
                                    <TextBlock.ToolTip>
                                        <Grid>
                                            <Grid.Resources>
                                                <conv:DateTimeToIsoConverter x:Key="dateToIso"/>
                                            </Grid.Resources>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto"/>
                                                <RowDefinition Height="Auto"/>
                                                <RowDefinition Height="Auto"/>
                                                <RowDefinition Height="Auto"/>
                                                <RowDefinition Height="Auto"/>
                                            </Grid.RowDefinitions>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto"/>
                                                <ColumnDefinition Width="Auto"/>
                                            </Grid.ColumnDefinitions>
                                            <TextBlock Text="{x:Static p:Resources.Dienstplan}" FontSize="14" FontWeight="Bold" Grid.ColumnSpan="3"/>
                                            <TextBlock Text="{x:Static p:Resources.PlanId}" FontWeight="Heavy" Grid.Row="1" Margin="5,10,10,0"/>
                                            <TextBlock Text="{Binding Collection.PlanId}" Grid.Row="1" Grid.Column="1" Margin="0,10,0,0"/>
                                            <TextBlock Text="{x:Static p:Resources.Von}" FontWeight="Heavy" Grid.Row="2" Margin="5,0,10,0"/>
                                            <TextBlock Text="{Binding Collection.Von, Converter={StaticResource dateToIso}}" Grid.Row="2" Grid.Column="1"/>
                                            <TextBlock Text="{x:Static p:Resources.Bis}" FontWeight="Heavy" Grid.Row="3" Margin="5,0,10,0"/>
                                            <TextBlock Text="{Binding Collection.Bis, Converter={StaticResource dateToIso}}" Grid.Row="3" Grid.Column="1"/>
                                            <TextBlock Text="{x:Static p:Resources.Layout}" FontWeight="Heavy" Grid.Row="4" Margin="5,0,10,0"/>
                                            <TextBlock Text="{Binding Collection.Schema}" Grid.Row="4" Grid.Column="1"/>
                                        </Grid>
                                    </TextBlock.ToolTip>                                    
                                </TextBlock>
                        </MenuItem.Header>

                        <MenuItem Header="{x:Static p:Resources.Print}" InputGestureText="Ctrl+P" Command="{Binding PrintCommand}" >
                            <MenuItem.Icon>
                                <Image Source="/personalplaner.gui;component/resources/images/Printer.png" />
                            </MenuItem.Icon>
                        </MenuItem>

                        <Separator/>

                        <MenuItem Header="{x:Static p:Resources.Refresh}" Command="{Binding RefreshPlanCommand}">
                            <MenuItem.Icon>
                                <Image Source="/personalplaner.gui;component/resources/images/Refresh.png" />
                            </MenuItem.Icon>
                        </MenuItem>
                        

                        <Separator/>

                        <MenuItem Header="{x:Static p:Resources.Close}" Command="{Binding ClosePlanCommand}"/>

                    </MenuItem>
                    <MenuItem Header="{x:Static p:Resources.Bearbeiten}">
                        <MenuItem Header="{x:Static p:Resources.LayoutBearbeiten}" Command="{Binding EditSchemaCommand}"/>
                        <Separator/>
                        <MenuItem Header="{x:Static p:Resources.TermineBearbeiten}" IsEnabled="False"/>
                        <MenuItem Header="{x:Static p:Resources.SaldosAnpassen}" Command="{Binding EditSaldoCommand}"/>
                    </MenuItem>
                    <MenuItem Header="{x:Static p:Resources.Extras}">
                        <MenuItem Header="{x:Static p:Resources.DiensteAutomatischEinteilen}" Command="{Binding PlanAutomationCommand}"/>
                        <MenuItem Header="{x:Static p:Resources.RecalculateSaldos}" Command="{Binding RecalculateSaldosCommand}"/>
                        <Separator/>
                        <MenuItem Header="{x:Static p:Resources.PlanAbschliessen}" Command="{Binding PlanAbschliessenCommand}">
                            <MenuItem.Icon>
                                <Image Width="16"/>
                            </MenuItem.Icon>
                        </MenuItem>
                        <MenuItem Header="{x:Static p:Resources.DeletePlan}" Command="{Binding DeletePlanCommand}">
                            <MenuItem.Icon>
                                <Image Source="/personalplaner.gui;component/resources/images/Delete.png"/>
                            </MenuItem.Icon>
                        </MenuItem>
                    </MenuItem>
                </Menu>
            </Grid>
        </Border>

        <c:PlanGrid Grid.Row="1" Collection="{Binding Collection}" PlanDienstOverview="{Binding DienstOverviewRows}"  Margin="5" Command="{Binding CellClickedCommand}" ShowPensumColumn="{Binding ShowPensumInPlan}" />
    </Grid>
        
</c:BaseControl>
